package com.esd.crm.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.esd.crm.entity.Doc;
import com.esd.crm.mapper.DocMapper;
import com.esd.crm.service.DocService;
import com.esd.vo.PageUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

@Service
public class DocServiceImpl implements DocService {

	@Autowired
	private DocMapper docDao;
	
	
	@Override
	public PageInfo<Doc> findDocByPage(Doc doc, PageUtil page) {
		PageHelper.startPage(page.getNowPage(), page.getNowRows());
		List<Doc> docs = docDao.findAll(doc);
		PageInfo<Doc> pageInfo = new PageInfo<>(docs);
		return pageInfo;
	}

	@Override
	public List<Doc> findAll(Doc doc){
		return docDao.findAll(doc);
	}
	
	@Override
	public Doc findOneByDocName(String name){
		return docDao.findOneByDocName(name);
	}
	
	@Override
	public boolean insertSelective(Doc record){
		return docDao.insertSelective(record);
	}
	
	@Override
	public Doc findOneByDocId(String id){
		return docDao.findOneByDocId(id);
	}
	
	public List<Doc> findOneByDocId1(String id){
		return docDao.findOneByDocId1(id);
	}
	
	@Override
	public boolean updateByPrimaryKeySelective(Doc doc){
		Date date = new Date();
		doc.setUpdateTime(date);
		return docDao.updateByPrimaryKeySelective(doc);
	}
	
	@Override
	public boolean deleteBatch(String[] ids){
		return docDao.deleteBatch(ids);
	}
	
	@Override
	public boolean deleteByPrimaryKey(String id){
		return docDao.deleteByPrimaryKey(id);
	}
	
	
}
